#include "outline_dock.h"
#include <QCloseEvent>
#include <QSettings>
#include <QDir>
#include <QFileInfo>

OutlineDock::OutlineDock(const QString& plgPath, const QString &title, QWidget *parent,Qt::WindowFlags flags)
                        : QDockWidget( title, parent, flags )
{
    QDir plgDir = QFileInfo(plgPath).absoluteDir();
    m_settingPath = plgDir.absolutePath();
    m_settingPath += QDir::separator();
    m_settingPath += "hell_plugin/hell_plugin.ini";
}

void OutlineDock::closeEvent(QCloseEvent *event)
{
    set_config("show", "false");

    QDockWidget::closeEvent(event);
}


void OutlineDock::set_config(const char* key, const char* value)
{
    QSettings configIni = QSettings(m_settingPath, QSettings::IniFormat);

    configIni.setValue(QString("outline/%1").arg(key), value);
}

QString OutlineDock::get_config(const char* key)
{
    QSettings configIni = QSettings(m_settingPath, QSettings::IniFormat);

    QVariant val = configIni.value(QString("outline/%1").arg(key));

    return val.toString();
}
